<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{$site_name}</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Font Awesome -->
    <link rel="stylesheet" href="/static/admin/adminlte/plugins/fontawesome-free/css/all.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- icheck bootstrap -->
    <link rel="stylesheet" href="/static/admin/adminlte/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/static/admin/adminlte/dist/css/adminlte.min.css">
    <!-- Google Font: Source Sans Pro -->
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <b>{$site_name}管理平台</b>
<!--        <a href="index/index2.html"><b>管理员</b></a>-->
    </div>
    <!-- /.login-logo -->
    <div class="card">
        <div class="card-body login-card-body">
            <p class="login-box-msg">登录</p>

<!--            <form action="index/index3.html" method="post">-->
                <div class="input-group mb-3">
                    <input type="email" class="form-control" id="user_name" placeholder="用户名">
                    <div class="input-group-append">
                        <div class="input-group-text">
                            <span class="fas fa-envelope"></span>
                        </div>
                    </div>
                </div>
                <div class="input-group mb-3">
                    <input type="password" class="form-control" id="user_pass" placeholder="密码">
                    <div class="input-group-append">
                        <div class="input-group-text">
                            <span class="fas fa-lock"></span>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-8">
                        <div class="icheck-primary">
                            <input type="checkbox" id="remember">
                            <label for="remember">
                                记住密码
                            </label>
                        </div>
                    </div>
                    <!-- /.col -->
                    <div class="col-4">
                        <button type="submit" class="btn btn-primary btn-block" id="btnLogin">登录</button>
                    </div>
                    <!-- /.col -->
                </div>
<!--            </form>-->
        </div>
        <!-- /.login-card-body -->
    </div>
</div>
<!-- /.login-box -->

<!-- jQuery -->
<!--{js href="/static/public/jquery/jquery.min.js" /}-->

<script src="/static/admin/adminlte/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="/static/admin/adminlte/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="/static/admin/adminlte/dist/js/adminlte.min.js"></script>
<!-- layer-->
{js href="/static/public/layer/layer.js" /}
<script type="text/javascript">
    $(document).keydown(function (event) {

        var enter = event.KeyCode || window.event.KeyCode;  //如果点击的为Ctrl键，ctrl为true

        switch (event.keyCode) {
            case 13:
                login();
        }
    })

    $("#btnLogin").click(function () {
        login();
    });

    function login() {
        var name = $("#user_name").val();
        var pass = $("#user_pass").val();
        if (name === "" || name == null) {
            layer.msg("请填写用户名");
            return false;
        }
        if (pass == null || pass === "") {
            layer.msg("请填写密码")
            return false;
        }
        $.ajax({
            url: "{:url('admin/login/login')}",
            type: 'post',
            data: {'name': name, 'pass': pass},
            dataType: 'json',
            success: function (data) {
                if (data.status === 1) {
                    layer.msg(data.msg);
                    location.href = "{:url('admin/index/index')}";
                } else {
                    layer.msg(data.msg);
                }
            },
            error: function () {
                console.log('请求出错！');
            }
        })
    }
</script>
</body>
</html>
